var ns = function(val) {
  return (function(names, last) {
    var name = names.shift();
    last[name] = last[name] || {};
    return names.length === 0 ? 
      last[name] : arguments.callee(names, last[name]);
  })(val.split('.'), window);
};
